//
//  SpotImgPlaceholderCell.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/6.
//

import UIKit

class SpotImgPlaceholderCell: UICollectionViewCell {
    typealias ClickImageViewCellBlock = () -> Void
    var clickImageViewCellBlock : ClickImageViewCellBlock!
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.backgroundColor = UIColor.init(hexString: "#D8D8D8")
        self.contentView.isUserInteractionEnabled = true
        self.contentView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(tagDidImageViewCLick)))
        self.setupView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setupView() {
        self.contentView.addSubview(self.imageView)
        self.contentView.addSubview(self.textNumLab)
        self.contentView.addSubview(self.detailLab)
        imageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(22)
            make.centerX.equalTo(self.snp.centerX);
            make.centerY.equalTo(self.snp.centerY).offset(-20);
        }
        detailLab.snp.makeConstraints { (make) in
            make.top.equalTo(self.imageView.snp.bottom).offset(8);
            make.left.equalTo(self.contentView.snp.left).offset(2);
            make.right.equalTo(self.contentView.snp.right).offset(2);
            make.centerX.equalTo(self.snp.centerX);
            make.height.greaterThanOrEqualTo(10)
        }
        textNumLab.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.snp.centerX);
            make.top.equalTo(self.detailLab.snp.bottom).offset(5);
            make.height.equalTo(10)
        }
    }
    @objc func tagDidImageViewCLick() {
        if (clickImageViewCellBlock != nil) {
            clickImageViewCellBlock()
        }
    }
    lazy var imageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage.init(named: "sender_camera")
        return imageView
    }()
    lazy var textNumLab: UILabel = {
        let textNumLab = UILabel.init()
        textNumLab.textColor = UIColor.init(hexString: "#535252")
        textNumLab.text = "0/3"
        textNumLab.font = UIFont.systemFont(ofSize: 9)
        return textNumLab
    }()
    lazy var detailLab:UILabel = {
        let detailLab = UILabel.init()
        detailLab.textColor = UIColor.init(hexString: "#A7A7A7")
        detailLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_goods_uploadPhoto)
        detailLab.numberOfLines = 0
        detailLab.font = UIFont.systemFont(ofSize: 10)
        detailLab.textAlignment = .center
        return detailLab
    }()
}
